package com.xomily.devops.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xomily.common.annotation.Log;
import com.xomily.common.core.controller.BaseController;
import com.xomily.common.core.domain.AjaxResult;
import com.xomily.common.enums.BusinessType;
import com.xomily.devops.domain.DevProgram;
import com.xomily.devops.service.IDevProgramService;
import com.xomily.common.utils.poi.ExcelUtil;
import com.xomily.common.core.page.TableDataInfo;

/**
 * 进程信息Controller
 * 
 * @author xomily
 * @date 2021-11-29
 */
@RestController
@RequestMapping("/devops/program")
public class DevProgramController extends BaseController
{
    @Autowired
    private IDevProgramService devProgramService;

    /**
     * 查询进程信息列表
     */
    @PreAuthorize("@ss.hasPermi('devops:program:list')")
    @GetMapping("/list")
    public TableDataInfo list(DevProgram devProgram)
    {
        startPage();
        List<DevProgram> list = devProgramService.selectDevProgramList(devProgram);
        return getDataTable(list);
    }

    /**
     * 导出进程信息列表
     */
    @PreAuthorize("@ss.hasPermi('devops:program:export')")
    @Log(title = "进程信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(DevProgram devProgram)
    {
        List<DevProgram> list = devProgramService.selectDevProgramList(devProgram);
        ExcelUtil<DevProgram> util = new ExcelUtil<DevProgram>(DevProgram.class);
        return util.exportExcel(list, "进程信息数据");
    }

    /**
     * 获取进程信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('devops:program:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(devProgramService.selectDevProgramById(id));
    }

    /**
     * 新增进程信息
     */
    @PreAuthorize("@ss.hasPermi('devops:program:add')")
    @Log(title = "进程信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DevProgram devProgram)
    {
        return toAjax(devProgramService.insertDevProgram(devProgram));
    }

    /**
     * 修改进程信息
     */
    @PreAuthorize("@ss.hasPermi('devops:program:edit')")
    @Log(title = "进程信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DevProgram devProgram)
    {
        return toAjax(devProgramService.updateDevProgram(devProgram));
    }

    /**
     * 删除进程信息
     */
    @PreAuthorize("@ss.hasPermi('devops:program:remove')")
    @Log(title = "进程信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(devProgramService.deleteDevProgramByIds(ids));
    }
}
